function getIframeDomain(parentDomain) {
  var iframeDomain = parentDomain;
  iframeDomain = iframeDomain.replace(/^[^.]+.google.com/, "www.google.com");
  iframeDomain = iframeDomain.replace(/^(api.)?0/, "ssl.0");
  return iframeDomain;
}

function getIframePort(location) {
  return location.hostname.indexOf("corp") > -1 ? ":" + location.port : "";
}

function getIframeProtocol(parentDomain) {
  return parentDomain.indexOf("corp") > -1 ? "http" : "https";
}

function getIframeUrl(location) {
  return getIframeProtocol(location.hostname) + "://" +
         getIframeDomain(location.hostname) + getIframePort(location) +
         "/base/api/demo/authsub/html/upgradeToken.html";
}

function setAuthSubIframeSrc() {
  document.getElementById("authSubIframe").src =
    getIframeUrl(window.location);
}